<template>
	<view class="content" >
			<view v-if="show_main" class="main" >
				<view style="height: 30px;background: #2979ff;"></view>
				<view class="f32 pr" style="padding: 10rpx 30rpx;background: #2979ff;height: 340rpx;text-align: center;color:#fff;">
					<view @click="goPage" data-uri="/pages/user-data/user-data" class="mt50">
						<view class="pr" style="display: inline-block;">
						  <image :src="user.head_pic" style="border-radius: 50%;width: 150rpx;height: 150rpx;"></image>
						  
						  <view v-if="user.sex == 1" class="pa" style="bottom:10rpx;right: -12rpx;background: #fff;border-radius: 50%;width:46rpx;height: 46rpx;">
							  <u-icon name="a-nan1" color="#06afe7" custom-prefix="qxl-icon" size="47"></u-icon>
						  </view>
						  <view v-else-if="user.sex == 2" class="pa" style="bottom:10rpx;right: -12rpx;background: #fff;border-radius: 50%;width:52rpx;height: 53rpx;">
						  		<u-icon name="nv1" color="#e443a6" custom-prefix="qxl-icon" size="50"></u-icon>
						  </view>
						  
					    </view>
					</view>
				    <view @click="goPage" data-uri="/pages/user-data/user-data">{{user.nickname}}<u-icon name="edit-pen-fill" color="#eeeeee" size="44"></u-icon></view>
					<view class="mt5">帐号:{{user.id}}</view>
		
					<!--<view class="pa bgf box-shadow4" style="width: 620rpx;height: 80px;left:70rpx;bottom:-40px;z-index: 9999;border-radius: 6px;">
						<view class="disfr-lr">  
							<view>
								
							</view>
						</view>
					</view>-->
				</view>
				<!--<view style="height: 50px;"></view>-->
				<view @click="goPage" data-uri="/pages/user-gold-coin/user-gold-coin" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="xunibi" color="#f60" custom-prefix="qxl-icon" size="40"></u-icon>
						<text>{{virtual_coin_name}}</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
                        <text class="pr" style="top:5rpx;">{{user.coin_number}}</text>
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				<view v-if="showBusiness" @click="goPage" data-uri="/pages/user-business-list/user-business-list" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="shangji" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:3rpx;" size="48"></u-icon>
						<text>我的商机</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				<view v-if="showGroup" @click="goPage" data-uri="/pages/user-my-group/user-my-group" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="kehuqunzu" color="#f60" custom-prefix="qxl-icon" style="position: relative;top:3rpx;" size="48"></u-icon>
						<text>我的群聊</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
				        <text v-if="$vuex.state.globalData.groupApplicationCount > 0" class="pr" 
						style="top:5rpx;display: inline-block;
						width:44rpx;
						height: 44rpx;
						background: red;color:#fff;
						border-radius: 50%;
						font-size: 22rpx;
						text-align: center;
						line-height: 44rpx;
						top:8rpx;
						">{{$vuex.state.globalData.groupApplicationCount}}</text>
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				<view v-if="showBusiness" @click="goPage" data-uri="/pages/user-business-collect/user-business-collect" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="a-shoucang1" color="#07C160" custom-prefix="qxl-icon" style="position: relative;top:3rpx;" size="48"></u-icon>
						<text>收藏商机</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				
				<view v-if="showBusiness" @click="goPage" data-uri="/pages/user-business-chat/user-business-chat" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="faxiaoxi" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:3rpx;" size="42"></u-icon>
						<text>我私聊过的商机</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				
				<view v-if="showBusiness" @click="goPage" data-uri="/pages/user-guarantee/user-guarantee" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="shezhi" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="44"></u-icon>
						<text>担保交易</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				
				<view @click="goPage" data-uri="/pages/user-follow/user-follow" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="a-31guanzhu1-xuanzhong" color="red" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="48"></u-icon>
						<text>帐号关注</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				<view @click="goPage" data-uri="/pages/user-set/user-set" class="bgf p30 f32 disfr-lr bto"><!--@click="goPage"-->
					<view class="pt10">
						<u-icon name="shezhi" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="44"></u-icon>
						<text>设置</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				
				<view @click="showDuifang" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="lianxiduifang" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="44"></u-icon>
						<text>客服</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>
				
				<!--<view @click="goPage" data-uri="/pages/drift/my-bottle" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="shezhi" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="44"></u-icon>
						<text>漂流瓶开发入口</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>-->
				
				<!--<view @click="goPage" data-uri="/pages/guarantee/guarantee" class="bgf p30 f32 disfr-lr bto">
					<view class="pt10">
						<u-icon name="shezhi" color="#2979ff" custom-prefix="qxl-icon" style="position: relative;top:4rpx;" size="44"></u-icon>
						<text>担保交易开发入口</text>
					</view>
					<view class="disf pr col999" style="top:5rpx;">
						<u-icon name="arrow-right" size="44"></u-icon>
					</view>
				</view>-->
				
			</view>
			<view style="height: 50px;"></view>
		<!--<loading :loading="not_load"/><!--加载状态-->
		
			<u-tabbar v-model="$vuex.state.globalData.tabBar.current" height="105rpx" icon-size="40rpx"
			:list="$vuex.state.globalData.tabBar.list" active-color="#2979ff" 
			:mid-button="false"></u-tabbar><!--自定义底部导航 icon-size="40rpx" -->
		
		<u-no-network tips="哎呀，网络信号丢失"></u-no-network><!--检测网络-->
		
		<!--客服层 -->
		<u-popup v-model="customer_pop" mode="bottom" :round="10" :closeable="true">
			<view class="customer_pop">
				<view class="mt30 pl30 f34">联系客服</view>
				<view class="p30 mt30">
					
					<view class="f34 disf">
						<view class="col999" style="width: 140rpx;">名称：</view>
						<view>{{customer.cn_title}}</view>
					</view>
					
					<view class="f34 disf mt20">
						<view class="col999" style="width: 140rpx;">电话：</view>
						<view class="disf" @click="copy" :data-text="customer.telephone">
						 <text>{{customer.telephone}}</text>
						 <image src="/static/image/copy-text.png" style="width: 40rpx;height: 40rpx;top:2rpx;margin-top: 4rpx;" ></image>
						</view>
					</view>
					
					<view class="f34 disf mt20">
						<view class="col999" style="width: 140rpx;">微信：</view>
						<view>
							<view class="disf" @click="copy" :data-text="customer.wechat_number">
								<text>{{customer.wechat_number}}</text>
								<image src="/static/image/copy-text.png" style="width: 40rpx;height: 40rpx;top:2rpx;margin-top: 4rpx;" ></image>
							</view>
						</view>
					</view>
					
					<view class="f34 disf mt20" >
						<view class="col999" style="width: 140rpx;">Email：</view>
						<view>
							<view class="disf" @click="copy" :data-text="customer.email">
							<text>{{customer.email}}</text>
							<image src="/static/image/copy-text.png" style="width: 40rpx;height: 40rpx;top:2rpx;margin-top: 4rpx;" ></image>
						   </view>
						</view>
					</view>
					
					<view v-if="customer.cn_contacts" class="f34 disf mt20" >
						<view class="col999" style="width: 140rpx;">联系人：</view>
						<view>{{customer.cn_contacts}}</view>
					</view>
				    <view style="height: 50rpx;"></view>
				</view>
			</view>
		</u-popup>
				
					
	</view>
</template>

<script setup>
import { onLoad, onShow, onHide, onReachBottom, onPullDownRefresh } from '@dcloudio/uni-app';
import { ref } from 'vue';	
const show_main=ref(false);
const not_load=ref(false);
const user=ref({});
const customer=ref({});
const virtual_coin_name=ref('');
const showGroup=ref(false);
const showBusiness=ref(false);
//页面加载时
onLoad(async (options)=>{
   uni.offNetworkStatusChange(connected)
   uni.onNetworkStatusChange(connected);
   //console.log(uni.$vuex.state.globalData.tabBar.list);
   for(let i in uni.$vuex.state.globalData.tabBar.list){
	   if(uni.$vuex.state.globalData.tabBar.list[i].pagePath == '/pages/group/group') {
		   showGroup.value=true;
	   }
	   if(uni.$vuex.state.globalData.tabBar.list[i].pagePath == '/pages/business/business') {
	   		   showBusiness.value=true;
	   }
   }
   //console.log('showGroup',showGroup.value);
});
const connected=(res)=>{
	if(res.isConnected){
		loadPage({},false);
	}
};
//页面显示时执行
onShow(()=>{
	//console.log('语法糖onShow');
	 loadPage({},false);
});
//页面隐藏时执行
onHide(()=>{
	//console.log('语法糖onHide');
});
/**
 * 加载接口数据
 * @param {Object} options  参数,对像数组
 * @param {Object} isPage   是否加载大于1页
 */
const loadPage=async (options,isPage)=>{
	let ret = await uni.$get('/appapi-member-index',options);
	if(ret.error_code != 0){
		show_main.value=true;
		not_load.value=true;
		uni.$utils.showToast(ret.info,0,()=>{
			uni.navigateBack({data:1});
		});
		return;
	}
	//console.log(ret.data);
	show_main.value=true;
	not_load.value=true;
	user.value=ret.data.user;
	customer.value=ret.data.customer;
	virtual_coin_name.value=ret.data.virtual_coin_name;
};
/**
 * 模板属性跳转页面
 * @param {Object} e
 */
function goPage(event){
	uni.$utils.dataSetPage(event);
};
const customer_pop=ref(false);
const showDuifang=()=>{
	customer_pop.value=true;
};
//复制文本
const copy =(e)=>{
	let text=e.currentTarget.dataset.text;
	uni.setClipboardData({
		data: text,
		success: function () {
		  uni.showToast({
			title: '复制成功',
			icon: 'success',
			duration: 2000
		  });
		},
		fail: function () {
		  //console.log('复制失败');
		  // 可以添加错误处理或用户友好的提示
		}
	});
}
</script>

<style  lang="scss">
	page {
		
	}
.fnow{color:#2979ff;}
.my_button{
	color:#fff;
	font-weight: normal;
	font-size: 32rpx;
	border:none;
	background: blue;
	background: #2979ff;
}
</style>
